package com.sea.onlinejudge.common;



public class BaseData {
    private int code = 500;
    private String message = "";
    private Object data;

    public final static int ERROR = 401;
    public final static int SUCCESS = 200;
    public final static int FAIL = 500;
    public final static int TOKENFAIL = 1000;

    public static BaseData success(String msg) {
        BaseData baseData = new BaseData();
        baseData.setCode(SUCCESS);
        baseData.setMessage(msg);
        return baseData;
    }

    public static BaseData success() {
        BaseData baseData = new BaseData();
        baseData.setCode(SUCCESS);
        baseData.setMessage("请求成功");
        return baseData;
    }

    public static BaseData error(String msg) {
        BaseData baseData = new BaseData();
        baseData.setCode(FAIL);
        baseData.setMessage(msg);
        return baseData;
    }

    public static BaseData error(int code, String msg) {
        BaseData baseData = new BaseData();
        baseData.setCode(code);
        baseData.setMessage(msg);
        return baseData;
    }

    public static BaseData error() {
        return error(500, "未知异常，请联系管理员");
    }

    public int getCode() {
        return code;
    }

    public BaseData setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public BaseData setMessage(String message) {
        this.message = message;
        return this;
    }

    public Object getData() {
        return data;
    }

    public BaseData setData(Object data) {
        this.data = data;
        return this;
    }
}
